package com.lanou.impl;

import com.lanou.mapper.controllerMoney;
import com.lanou.pojo.*;
import com.lanou.service.controllerService;
import org.springframework.stereotype.Service;

import javax.annotation.Resource;
import java.util.Date;
import java.util.List;
import java.util.Random;
import java.util.UUID;

@Service
public class controllerServiceImpl implements controllerService {
    @Resource
    private controllerMoney controllerMoney;



//生成一串随机数
    public static String generateRandomNumber(int length) {
        Random random = new Random();
        StringBuilder stringBuilder = new StringBuilder();

        for (int i = 0; i < length; i++) {
            int randomNumber = random.nextInt(10);
            stringBuilder.append(randomNumber);
        }

        return stringBuilder.toString();
    }

    @Override
    public List<ConfigHouseEntity> selectControllerMessage(String resourceName) {
        List<ConfigHouseEntity> configHouseEntity = controllerMoney.selectControllerMessage(resourceName);
        System.out.println(configHouseEntity);
        return configHouseEntity;
    }

    @Override
    public List<String>  selectResourceName() {
        List<String> strings = controllerMoney.selectResourceName();

        return strings;

    }

    @Override
    public List<String> configFeeItemName() {
        List<String> strings = controllerMoney.configFeeItemName();
        return strings;
    }

    @Override
    public List<PaymentContractEntity> selectPaymentConstract(String resourceName) {
        List<PaymentContractEntity> paymentContractEntities = controllerMoney.selectPaymentConstract(resourceName);
        return paymentContractEntities;
    }

    @Override
    public List<PaymentBillEntity> selectPaymentBill(String resourceName) {
        List<PaymentBillEntity> paymentBillEntities = controllerMoney.selectPaymentBill(resourceName);
        System.out.println(paymentBillEntities);
        return paymentBillEntities;
    }

    @Override
    public List<PaymentPayLogEntity> selectPaymentPayLog(String resourceName) {
        List<PaymentPayLogEntity> paymentPayLogEntities = controllerMoney.selectPaymentPayLog(resourceName);
        return paymentPayLogEntities;
    }

    @Override
    public List<PaymentTempEntity> selectPaymentTemp(String resourceName) {
        List<PaymentTempEntity> paymentTempEntities = controllerMoney.selectPaymentTemp(resourceName);
        return paymentTempEntities;
    }

    @Override
    public void addPaymentTemp( String resourceName, String feeUser, String feeItemName, String payType, String amt, Date operateTime) {
       String id=generateRandomNumber(19);
       String resourceId=generateRandomNumber(19);
       String feeItemId=generateRandomNumber(19);
       controllerMoney.addPaymentTemp(id,resourceId,feeItemId,resourceName,feeUser,feeItemName,payType,amt,operateTime);
    }
}
